Skip to content

Silence protobuf sun.misc.Unsafe warnings from the direct header comp… - #375

Open
davido wants to merge 1 commit into
bazelbuild:masterfrom
davido:turbine-direct-unsafe-memory-access
Open

Silence protobuf sun.misc.Unsafe warnings from the direct header comp…#375
davido wants to merge 1 commit into
bazelbuild:masterfrom
davido:turbine-direct-unsafe-memory-access

Conversation

@davido

@davido davido commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

…iler

turbine_direct (header_compiler_direct) bundles protobuf, whose UnsafeUtil calls terminally-deprecated sun.misc.Unsafe methods. On JDK 24+ (JEP 498) the JVM prints a warning for each such call during header compilation:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by
com.google.protobuf.UnsafeUtil (.../java_tools/turbine_direct_binary_deploy.jar)

Unlike the Turbine worker, header_compiler_direct does not receive turbine_jvm_opts, and --jvmopt does not reach header-compilation actions, so a toolchain currently has no way to silence these warnings for the direct header compiler. Add --sun-misc-unsafe-memory-access=allow to header_compiler_direct_jvm_opts, gated on the runtime feature version since the flag is rejected on JDK <= 22.

See protocolbuffers/protobuf#20760.

Closes #374

@davido
davido requested review from a team and hvadehra as code owners August 16, 2026 19:56
@davido
davido force-pushed the turbine-direct-unsafe-memory-access branch from cf27565 to 68de125 Compare August 18, 2026 05:29
Comment thread java/common/rules/java_toolchain.bzl Outdated
@davido
davido force-pushed the turbine-direct-unsafe-memory-access branch from 68de125 to 8d5a82c Compare August 19, 2026 13:04
Comment thread java/common/rules/java_toolchain.bzl Outdated
Comment thread java/common/rules/java_toolchain.bzl Outdated
Comment thread java/common/rules/java_toolchain.bzl Outdated
Comment thread toolchains/default_java_toolchain.bzl Outdated
@davido
davido force-pushed the turbine-direct-unsafe-memory-access branch from 8d5a82c to 49bcb6e Compare August 19, 2026 18:33
Expose an attribute to pass options to the direct header compiler, for
example to allow JDK 24+ sun.misc.Unsafe access for TurbineDirect's
bundled protobuf (protocolbuffers/protobuf#20760). Options pass through
as-is.

These are only meaningful for a JVM direct header compiler such as
TurbineDirect's deploy jar; a native turbine_direct_graal parses them as
Turbine command-line options, which the attribute docs warn against.

Closes bazelbuild#374
@davido
davido force-pushed the turbine-direct-unsafe-memory-access branch from 49bcb6e to da635b6 Compare August 19, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

header_compiler_direct (TurbineDirect) emits protobuf sun.misc.Unsafe warnings on JDK 24+ that no toolchain option can silence

2 participants